<?
//status: regmail:0 ; off: 1; onchat:2; oncpanel: 3 ; lock:4
$id=  isset($_POST['id'])        ?    intval($_POST['id']): $id;
$username= isset($_POST['username']) ? $_POST['username'] : "";
$password= isset($_POST['password']) ? $_POST['password'] : "";
$RoomName= isset($_POST['RoomName']) ? $_POST['RoomName'] : "";
if(empty($RoomName))$RoomName=$username;
$email= isset($_POST['email']) ? $_POST['email'] : "";

if($id>0 && !empty($username) && !empty($RoomName) && !empty($email))
{
	$uppass="";
	if(!empty($password))
	{
		$password=md5($password);
		$uppass=" cPassword = '$password', ";
	}
	$rs=$dbsql->query("select * from ".$GLOBALS['first_table']."tbluser where cUserName='$username' and iUserId<> $id");
	if($dbsql->num_rows($rs)>0)
	{
		$alert="User name '".$username."' is taken";
	}else
	{
		$sql_insert="update ".$GLOBALS['first_table']."tbluser set
				cUserName = '$username',
				".$uppass."
				cRoomName = '$RoomName',
				cEmail    = '$email' 
			where iUserId='$id'";
				
		$dbsql->query($sql_insert);
		
		$alert= "<center>Update Room ".$username." Success!";
	}
}

$sql_select="select * from  ".$GLOBALS['first_table']."tbluser where iUserId=".$_GET['id'];
$rs=$dbsql->query($sql_select);
$room=$dbsql->fetch_array($rs);
?>